package malus.shaofeng.com.beiwomusic.utils;

/**
 * Created by aaa on 15-3-17.
 */
public class PlayTimeUtil {

    public PlayTimeUtil() {
    }

    /**
     * 计算毫秒数代表的时间
     *
     * @param ms
     * @return
     */
    public static String calcTimeLenght(long ms) {
        String ret = "";
        long second = ms / 1000;
        long minute = second / 60;
        long hour = minute / 60;
        StringBuilder sb = new StringBuilder();

        if (hour > 0) {
            if (hour < 10) {
                sb.append('0');
            }
            sb.append(hour);

            sb.append(':');

        }

        if (minute > 0) {
            // TODO 分钟数现在是整个时间的总分钟数，需要求 % 60
            minute = minute % 60;
            if (minute < 10) {
                sb.append('0');
            }
            sb.append(minute);
        } else {
            sb.append("00");
        }

        sb.append(':');

        if (second > 0) {
            // TODO 当前描述是时间的总描述，需要 % 60
            second = second % 60;
            if (second < 10) {
                sb.append('0');
            }
            sb.append(second);
        } else {
            sb.append("00");
        }

        ret = sb.toString();
        sb = null;

        return ret;
    }
}
